import pandas as pd
import matplotlib.pyplot as plt
from test import get_coordinates

def visualize(path="./test.txt"):
    # 加载 point_coords 数据
    point_coords = pd.read_csv('point_coords.csv')
    print('point_coords数据基本信息：')
    point_coords.info()
    # 加载 router_coords 数据
    router_coords = pd.read_csv('router_coords.csv')
    print('router_coords数据基本信息：')
    router_coords.info()
    # 获取检测点坐标
    detected_point0 = get_coordinates(path)
    # 翻转纵坐标
    point_coords['纵坐标Y'] = 1200 - point_coords['纵坐标Y']
    router_coords['路由器纵坐标Y'] = 1200 - router_coords['路由器纵坐标Y']
    detected_point = (detected_point0[0], 1200 - detected_point0[1])
    # 设置图片清晰度
    plt.rcParams['figure.dpi'] = 300
    # 绘制点坐标，设置颜色为蓝色，形状为方形
    plt.plot(point_coords['横坐标X'], point_coords['纵坐标Y'], 's', color='blue', markersize=3, label='point_coords')
    # 绘制路由器坐标，设置颜色为红色，形状为圆点
    plt.plot(router_coords['路由器横坐标X'], router_coords['路由器纵坐标Y'], 'o', color='red', markersize=3, label='router_coords')
    # 绘制检测点坐标，设置颜色为绿色，形状为星形
    plt.plot(detected_point[0], detected_point[1], '*', color='green', markersize=10, label='detected_point')
    # 设置坐标轴范围
    plt.xlim(0, 1200)
    plt.ylim(0, 1200)
    # 设置标题和坐标轴标签
    plt.title('visualize point_coords and router_coords')
    plt.xlabel('X')
    # plt.xticks(rotation=45)
    plt.ylabel('Y')
    # 显示图例
    # plt.legend()
    # 显示图形
    plt.show()




if __name__ == "__main__":
    path="./wifi_data/point_22.txt"
    visualize(path)
